package com.yl.pattern.creatormodel.factory.simple_factory;

/**
 * @Author 小羊
 * @Date 29/10/2024下午 8:25
 * @ClassName SimpleCoffeeFactory
 * @Description 咖啡生产工厂
 */
public class SimpleCoffeeFactory {
    public Coffee createCoffee(String type){
        //声明Coffee类型的对象，根据不同的类型创建对象
        Coffee coffee = null;
        if("american".equals(type)){
            coffee = new AmericanCoffee();
        }else if("latte".equals(type)){
            coffee = new LatteCoffee();
        }else {
            throw new RuntimeException("对不起，你所点的咖啡没有");
        }
        return coffee;
    }

}
